<%--
  Created by IntelliJ IDEA.
  User: asus
  Date: 2020/5/26
  Time: 8:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="true"%>
<html>
<head>
    <title>采购审核</title>
    <%@include file="/comm/head.jsp"%>
</head>
<body>
<div id="root">

    <i-table :columns="columns" :data="pageResult.rows"  :height="300"  border stripe>

        <template slot-scope="{row}" slot="state">
            <span>{{row.state==0?"未审核":"已审核"}}</span>
        </template>
        <template slot-scope="{row}" slot="proName">
            <span>{{row.provider.proName}}</span>
        </template>

        <template slot-scope="{row}" slot="username">
            <span>{{row.user.username}}</span>
        </template>
        <template slot-scope="{row,index}"  slot="action">
            <i-button type="warning" @click="update(row)">审 核</i-button>
        </template>
    </i-table>

    <Page :total="pageResult.total"
          :page-size="pageSize"
          @on-change="pageNo=arguments[0];search();"
          show-sizer
          :page-size-opts="[5,10,15]"
          @on-page-size-change="pageSize=arguments[0];search();"
    />
</div>
<script>
    new Vue({
        el: "#root",
        data: {
            columns: [
                // {type: "selection", width: 60, align: "center"},//自动开启多选功能
                {key: "id", title: "编号"},
                {key: "createTime", title: "生成日期"},
                {key: "checkTime", title: "审核日期"},
                {key: "purchaseTime", title: "确认日期"},
                {title:"入库日期",key: "stockTime"},
                {title: "下单员",  slot: "username"},
                {title: "审核员",  key: "shenhe"},
                {title: "采购员",  slot: "username"},
                {title: "库管员",  key: "kuguan"},
                {slot: "proName", title: "供应商"},
                {title: "合计金额", key: "totalMoney"},
                {title: "状态", slot: "state"},
                {title: "运单号", key: "wayBillCode"},
                {title: "操作", slot: "action", width: 300}
            ],
            pageResult:{
                rows:[],
                total:50
            },
            pageNo:1,
            pageSize:5,
            providerList:[],
            order:{},
            orderdetail:{},
            searchFlag:false
        },
        methods:{
            search(){
                axios.get(`${ctx}/caiGou/shenhe/search/${this.pageNo}/${this.pageSize}`)
                    .then(({data})=>{
                        this.pageResult=data.result;
                    });
            },
            searchProvider(){
                axios.get(`${ctx}/sys/provider/list`)
                    .then(({data})=>{
                        this.providerList=data.result;
                    });
            },
            update(row,index){
                let _this=this;
                let params=Qs.stringify(this.order,{serializeDate:(date)=>{
                        return moment(date).format("YYYY-MM-DD");
                    }});
                let flag= iview.Modal.confirm({
                    title:"您确实要审核么？",
                    content:"该操作不可逆，请谨慎操作。",
                    onOk(){
                        axios.get(`${ctx}/caiGou/shenhe/update?id=${row.id}`,Qs.parse(params) )
                            .then(({data})=>{
                                iview.Message.success({content:data.msg});
                                _this.search();

                            });
                    }
                });
            },
            },
        mounted(){
            this.search();
            this.searchProvider();
        }
    });
</script>
</body>
</html>
